package com.yanqu.road.entity.servercenter;

import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.utils.string.StringUtils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@FieldTypeAnnotation(tableName = "t_s_auto_open_config", desc = "服务器自动开启配置")
public class ServerAutoOpenConfig {
    @FieldTypeAnnotation(update = true, desc = "渠道id", select = true)
    private int channelId;
    @FieldTypeAnnotation(desc = "1-创角  2-有效创角  3-注册人数")
    private int type;
    @FieldTypeAnnotation(desc = "有效创角判定等级")
    private int level;
    @FieldTypeAnnotation(desc = "地区分流配置")
    private String areaSplitFlow;

    private Map<String, Integer> areaRatioMap = new HashMap<>();

    public int getChannelId() {
        return channelId;
    }

    public void setChannelId(int channelId) {
        this.channelId = channelId;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public int getLevel() {
        return level;
    }

    public void setLevel(int level) {
        this.level = level;
    }

    public String getAreaSplitFlow() {
        return areaSplitFlow;
    }

    public void setAreaSplitFlow(String areaSplitFlow) {
        this.areaSplitFlow = areaSplitFlow;
    }

    public Map<String, Integer> getAreaRatioMap() {
        return areaRatioMap;
    }

    public void setAreaRatioMap(Map<String, Integer> areaRatioMap) {
        this.areaRatioMap = areaRatioMap;
    }

    public void parseAreaSplitFlow() {
        if (!StringUtils.isNullOrEmpty(areaSplitFlow)) {
            areaRatioMap = new HashMap<>();
            List<String> stringList = StringUtils.stringToStringList(areaSplitFlow, "\\|");
            for (String s : stringList) {
                List<String> stringList1 = StringUtils.stringToStringList(s, ";");
                areaRatioMap.put(stringList1.get(0), Integer.parseInt(stringList1.get(1)));
            }
        }
    }

}
